//package com.aaa.filter;
//
//import javax.servlet.*;
//import javax.servlet.annotation.WebFilter;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//
//@WebFilter("/*")
//public class LoginFilter implements Filter {
//    @Override
//    public void init(FilterConfig filterConfig) throws ServletException {
//    }
//
//    @Override
//    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
//        HttpServletRequest request = (HttpServletRequest) servletRequest;
//        HttpServletResponse response = (HttpServletResponse) servletResponse;
//        //获取当前请求的url /images/logo.jpg
//        String path = request.getRequestURI();
//        if ("/login.jsp".equals(path)
//                || "/staff/login".equals(path)
//                || path.contains("/images")
//                || path.endsWith(".css")
//                || path.endsWith(".js")
//        ) {
//            filterChain.doFilter(servletRequest, servletResponse);
//        }else{
//            //判断是否登录
//            Object staff = request.getSession().getAttribute("staff");
//            if(staff!=null){
//                filterChain.doFilter(servletRequest, servletResponse);
//            }else{
//                response.sendRedirect("/login.jsp");
//            }
//        }
//
//    }
//
//    @Override
//    public void destroy() {
//    }
//}
